const mongoose = require('mongoose')

const schema = new mongoose.Schema({
  name: {
    type: String
  },
  // 设置关联外键属性
  parent: {
    // 外键的类型可以是ObjectId, Number, String, Buffer中任何一种
    type: mongoose.SchemaTypes.ObjectId,
    ref: 'Category'
  }
})

module.exports = mongoose.model('Category', schema)